﻿<%@ Page Title="" Language="VB" MasterPageFile="./Site.master" AutoEventWireup="false"   %>
<script runat="server">
Private Sub InsertShipper (ByVal Source As Object, ByVal e As EventArgs)
  SqlDataSource1.Insert()
End Sub ' InsertShipper
</script>

  <head id="Head1" runat="server">
      <link href="Styles/site.css" rel="stylesheet" type="text/css" />
    <title>Test db page</title>
</head>

<body>
Title
    <form id="form2" runat="server">

      <asp:sqldatasource
        id="SqlDataSource1"
        runat="server"
        connectionstring="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\PrefHer\First\App_Data\PrefSec.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
        selectcommand="SELECT PID FROM PINT1"
        
          insertcommand="INSERT INTO PINT1 (PID,CompanyName,Phone) VALUES (@PID,@CoName,@Phone)" 
          ProviderName="System.Data.SqlClient">
          <insertparameters>
            <asp:formparameter name="PiD" formfield="PIDbox" />
            <asp:formparameter name="CoName" formfield="CompanyNameBox" />
            <asp:formparameter name="Phone"  formfield="PhoneBox" />
          </insertparameters>
      </asp:sqldatasource>

      <br />
      <asp:TextBox ID="PIDbox" runat="server"></asp:TextBox>

      <asp:RequiredFieldValidator
        id="RequiredFieldValidator3"
        runat="server"
        ControlToValidate="CompanyNameBox"
        Display="Static"
        ErrorMessage="Please enter a PID." />

      <br />
      <asp:textbox
           id="CompanyNameBox"
           runat="server" />

      <asp:RequiredFieldValidator
        id="RequiredFieldValidator1"
        runat="server"
        ControlToValidate="CompanyNameBox"
        Display="Static"
        ErrorMessage="Please enter a company name." />

      <br /><asp:textbox
           id="PhoneBox"
           runat="server" />

     <asp:RequiredFieldValidator
        id="RequiredFieldValidator2"
        runat="server"
        ControlToValidate="PhoneBox"
        Display="Static"
        ErrorMessage="Please enter a phone number." />

      <br /><asp:button
           id="Button1"
           runat="server"
           text="Insert New Shipper"
           onclick="InsertShipper" />

   </asp:Content>
   </form>
